package com.mazaiting.sms.factory;

import com.mazaiting.sms.config.SmsProperties;
import com.mazaiting.sms.service.ISmsService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * 服务配置
 *
 * @author mazaiting
 * @create_time 2022/10/2 19:50
 */
@Component
@RequiredArgsConstructor
public class ServiceFactory {

    private final SmsProperties smsProperties;

    private final ISmsService localSmsServiceImpl;
    private final ISmsService aliSmsServiceImpl;

    /**
     * 获取短信服务
     *
     * @return 短信服务
     */
    public ISmsService smsService() {
        return "LOCAL".equals(smsProperties.getType()) ? localSmsServiceImpl : aliSmsServiceImpl;
    }

}
